/*
 * @Author: your name
 * @Date: 2020-09-15 16:25:04
 * @LastEditTime: 2020-12-04 16:27:52
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \inventory-apie:\hjimi\人脸\html\face-recognition\src\api\user.js
 */
import request from '@/utils/request'

let apis = 'apis/api/user/'
/**
 * @description: 图片验证码获取
*/
export function verifycode() {
  return request({
    url: `${ apis }verifycode`,
    method: 'get',
    responseType: 'blob'
  })
}

// --------------------------------登录/注册---------------------------
// 注册
export function regist(data) {
  return request({
    url:  `${ apis }regist`, 
    method: 'post',
    data
  })
}

// 查询用户名是否可用
export function isUser(username) {
  return request({
    url:  `${ apis }regist/check/username/${username}`,
    method: 'get'
  })
}

// 查询邮箱是否可用
export function isEmail(email) {
  return request({
    url:  `${ apis }regist/check/email/${email}`,
    method: 'get'
  })
}

// 登录
export function login(params) {
  return request({
    url:  `${ apis }jwt/token/user`,
    method: 'post',
    data: params
  })
}
 
// 登出
export function logout() {
  return request({
    url:  `${ apis }jwt/logout`,
    method: 'post'
  })
}


// --------------------------------修改密码、修改邮箱、获取邮箱验证码-----------------------------------
// 获取邮箱验证码
/**
 * @description: 
 * @param {username,email} 
 * @return {type} 
 */
export function getAuthCode(data) {
  return request({
    url:  `${ apis }forgotpassword`,
    method: 'post',
    data
  })
}

// 修改密码
/**
 * @description: 
 * @param {username,email,token,username} 
 * @return {type} 
 */
export function resetpassword(data) { 
  return request({
    url:  `${ apis }resetpassword`,
    method: 'post',
    data
  })
}
 
 